Stored Procedures [dbo].[asi_GetRestockPrice]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@valuedecimal(18,4)9
@priceCodeint4
SQL Script
CREATE  PROCEDURE [dbo].[asi_GetRestockPrice]

@value decimal(18,4),
@priceCode int

AS

--Attempt to retrieve an appropriate restocking charge given an order value
SELECT COALESCE(
            (SELECT
                TOP 1 rp.Price
            FROM
                RestockPrice rp
            WHERE
                rp.MinAmount <= @value
                AND rp.RestockPriceCode = @priceCode
            ORDER BY rp.MinAmount DESC),
            -1)

GO
Uses